Method and system for matching music files with electroencephalogram

ABSTRACT

Disclosed are a method and a system for matching an electroencephalogram and music files which compares the scaling index α of an electroencephalogram with the long-range correlation index β, and matches music file with the electroencephalogram if the scaling index and the long-range correlation index close to equal so as to find a music file matched with a measured electroencephalogram automatically. The method and system in accordance with the present invention may automatically find music files matching with human brain statements in real time by measuring an electroencephalogram, and then guide people relieve stress and relax effectively.

CLAIM OF PRIORITY AND CROSS-REFERENCE TO RELATED APPLICATION(S)

This application is a continuation of International Application No. PCT/CN2014/086917, filed Sep. 19, 2014. The International Application claims priority to Chinese Patent Application No. 201410360309.1, filed on Jul. 25, 2014. The afore-mentioned patent applications are hereby incorporated by reference in their entireties.

BACKGROUND OF THE INVENTION 1. Field of the Invention

The present invention relates to the field of neurotechnology, and particularly to a method and a system for matching music files with an electroencephalogram.

2. Description of the Related Art

There are numerous symbol sequences with abundant information in the natural world, such as human languages created by human, sound tone (e.g. music) and noises defined by human, and gene sequences and neural signaling forming in natural processes. Different kinds of sequences may be matched to each other according to some common elements.

Music is one of the artistic forms which express human emotions in a most direct way, and has a very important influence and promotion impact on human emotions and its transformation. The research on mechanism in human brain concerning with emotional response caused by music is becoming one of the hotspots in many fields such as the cognitive neuroscience, pedagogy and psychology. As verified by prior researches, music can affect human's emotions, which could be observed by electroencephalogram analysis. Furthermore, different types of music and different stimulations methods could cause different excitement modes on human brains. Therefore, how these lead to emotions, and further guide the music chosen to relieve stress and get relax become very important for clinic.

For now researches concentrate on different influences on human brains caused by different types of music. However, the major disadvantage of prior art is selecting music roughly and subjectively. More specifically, prior art is not able to automatically select music files to help people achieve a desired brain statement such as relax according to their real-time brain waves.

BRIEF DESCRIPTION OF THE INVENTION

The technical problem to be solved by the present invention is that prior art is not able to automatically find music files matching with human brain statements in real time then guide people relieve stress and relax effectively.

In view of this, in the first aspect, the present invention provides a method for matching music files with an electroencephalogram. In step S1, a scaling index α is obtained in accordance with a measured electroencephalogram. In step S2, each music file in a preset music library is analyzed to obtain a long-range correlation index β. In step S3, a music file matching with the electroencephalogram is searched out in accordance with the comparison of scaling index α and the long-range correlation index β.

Preferably, the step S1 may comprise following steps.

In step S11, the measured electroencephalogram is digitized to obtain a discrete-time signal sequence {x_(i), i=1, 2, . . . , N}, wherein x_(i) is the ith sampling point of the electroencephalogram and N is the sampling size.

In step S12, the average amplitude

x

of the discrete-time signal sequence {x_(i), i=1, 2, . . . , N} is filtered to obtain a sequence {y_(i), i=1, 2, . . . , N}, wherein y_(i) is defined by the following formula.

${y_{i} = {\sum\limits_{k = 1}^{i}\left( {x_{k} - \left\langle x \right\rangle} \right)}},{i = {1\mspace{14mu}\ldots\mspace{14mu} N}},$ wherein,

$\left\langle x \right\rangle = {\frac{1}{N}{\sum\limits_{i = 1}^{N}\;{x_{i}.}}}$

In step S13, the EMD (Empirical Mode Decomposition) is applied to the sequence {y_(i), i=1, 2, . . . , N} to obtain n intrinsic mode functions IMF and a remainder R, wherein n is a positive integer determined by the EMD.

In step S14, peak-peak intervals (the number of data points between each neighboring local maximum) in each intrinsic mode function IMF are calculated.

In step S15, waveforms between peaks with peak-peak intervals within a first given range S are merged into a new waveform Pvalue_(s)(k), wherein 10^((m-1))≤s≤10^(m), m=1, 2, . . . , m_(max), and m_(max) is determined by the length N of the sequence {y_(i), i=1, 2, . . . , N}, and k represents each data point of the merged waveform, wherein k=1, 2, . . . , k_(max), and k_(max) is determined by the sum of all the peak-peak intervals within the first given range S.

In step S16, a root mean square of each merged waveform is calculated to obtain a wave function F.

$F = \left\lbrack {\frac{1}{Q}{\sum\limits_{k = 1}^{Q}{{Pvalue}_{s}^{2}(k)}}} \right\rbrack^{1/2}$

Wherein,

${Q = \frac{k_{\max}}{\left\langle s \right\rangle}},$ and <S> represents calculating an average in range S. With respect to different scale ranges S, F∝s^(α), wherein ∝ represents a directly proportional or scale relation between two subjects, and α is the scaling index.

In step S17, scaling index α is obtained in accordance with F∝s^(α).

Preferably, the step S2 further comprises following steps.

In step S21, each music file in the music library is digitized to obtain a digital music signal sequence {U_(i), i=1, 2, . . . , M}, wherein i is the ith time point of the digital music signal sequence, and M is the length of the digital music signal sequence.

In step S22, a sequence {v_(j), j=1, 2, . . . , M/(presetlength)} is obtained by dividing the digital music signal sequence {U_(i), i=1, 2, . . . , M} into multiple sub-sequences with a preset length and calculating the standard deviation of each sub-sequence, wherein v_(j) is the jth data of the sequence {v_(j), j=1, 2, . . . , M/(presetlength)}.

In step S23, an average intensity sequence {(v_(j))², j=1, 2, . . . , M/(presetlength)} is obtained in accordance with the sequence {v_(j), j=1, 2, . . . , M/(presetlength)}.

In step S24, a fluctuation sequence {z_(b), b=1, 2, . . . , M/(presetlength)} which is a one-dimensional random walk sequence is obtained in accordance with the average intensity sequence {(v_(j))², j=1, 2, . . . , M/(presetlength)}, wherein z_(b) is the bth data of the sequence {z_(b), b=1, 2, . . . , M/(presetlength)} which is defined by the following formula.

${z_{b} = {{\sum\limits_{j = 1}^{b}\left( v_{j} \right)^{2}} - \left\langle v^{2} \right\rangle}},$ wherein

$\left\langle v^{2} \right\rangle = {\frac{1}{M/{presetlength}} \times {\sum\limits_{j = 1}^{M/{presetlength}}\;{\left( v_{j} \right)^{2}.}}}$

In step S25, multiple sub-sequences are obtained by shifting a time window with preset width along the fluctuation sequence {z_(b), b=1, 2, . . . , M/(presetlength)}. Each two neighboring windows exist a fixed overlap length τ.

In step S26, a linear trend {circumflex over (z)}_(b) of each sub-sequence is obtained by mean of linear regression.

In step S27, a detrended fluctuation function F_(D)(presetwidth)=√{square root over (<(δz)²>)} is obtained in accordance with the sequence {z_(b), b=1, 2, . . . , M/(presetlength)} and the linear trend of each sub-sequence, wherein δz={circumflex over (z)}_(b)−z_(b), and √{square root over (<(δz)²>)} represents calculating the average of (δz)² in each time window.

In step S28, the long-range correlation index β is obtained in accordance with the detrended fluctuation function F_(D)(presetwidth) by means of following formula:

${\beta = \frac{d\;\log\;{F_{D}({presetwidth})}}{\;{d\;{\log\left( {{presewidth} + 3} \right)}}}},$ wherein,

$\frac{d\;\log\mspace{11mu}{F_{D}({presetwidth})}}{d\;\log\;\left( {{presewidth} + 3} \right)}$ represents the relation between detrended fluctuation function and the time scaling defined by the preset width of the time window derived from log-log plot.

Preferably, the step S3 further comprises following steps.

In step S31, γ is calculated in accordance with the scaling index α and the long-range correlation index β, wherein, γ=|α−β|.

In step S32, if γ is within a second given range, the music file with a long-range correlation index β is matched with the electroencephalogram with a scaling index α.

In a second aspect, the present invention provides a system for matching music files with an electroencephalogram which comprises an electroencephalogram scaling device, a music analysis device and a matching device. The electroencephalogram scaling device is configured to obtain a scaling index α in accordance with a measured electroencephalogram and to transmit the scaling index α to the matching device. The music analysis device is configured to analyze each music file in a preset music library to obtain a long-range correlation index β and to transmit β to the matching device. The matching device is configured to search out a music file matching with the electroencephalogram in accordance with the comparison of the scaling index α and the long-range correlation index β.

The system further comprises an electroencephalogram measuring device configured to measure an electroencephalogram and to transmit the electroencephalogram to the electroencephalogram scaling device.

Preferably, the electroencephalogram scaling device is configured to implement following steps.

In step S11, the measured electroencephalogram is digitized to obtain a discrete-time signal sequence {x_(i), i=1, 2, . . . , N}, wherein xi is the ith sampling point of the electroencephalogram and N is the sampling size.

In step S12, the average amplitude

x

of the discrete-time signal sequence {x_(i), i=1, 2, . . . , N} is filtered to obtain a sequence {y_(i), i=1, 2, . . . , N}, wherein y_(i) is defined by the following formula.

${y_{i} = {\sum\limits_{k = 1}^{i}\left( {x_{k} - \left\langle x \right\rangle} \right)}},{i = {1\mspace{14mu}\ldots\mspace{20mu} N}},$ wherein,

$\left\langle x \right\rangle = {\frac{1}{N}{\sum\limits_{i = 1}^{N}\;{x_{i}.}}}$

In step S13, the EMD (Empirical Mode Decomposition) is applied to the sequence {y_(i), i=1, 2, . . . , N} to obtain n intrinsic mode functions IMF and a remainder R, wherein n is a positive integer determined by the EMD.

In step S14, peak-peak intervals (the number of data points between each neighboring local maximum) in each intrinsic mode function IMF are calculated.

In step S15, waveforms between peaks with peak-peak intervals within a first given range S are merged into a new waveform Pvalue_(s)(k), wherein 10^((m-1))≤s≤10^(m), m=1, 2, . . . , m_(max), and m_(max) is determined by the length N of the sequence {y_(i), i=1, 2, . . . , N}, and k represents each data point of the merged waveform, wherein k=1, 2, . . . , k_(max), and k_(max) is determined by the sum of all the peak-peak intervals within the first given range S.

In step S16, root mean square of each merged waveform is calculated to obtain a wave function F.

${F = \left\lbrack {\frac{1}{Q}{\sum\limits_{k = 1}^{Q}{{Pvalue}_{s}^{2}(k)}}} \right\rbrack^{1/2}},$ wherein,

${Q = \frac{k_{\max}}{\left\langle s \right\rangle}},$ and <S> represents calculating an average in the given range S. With respect to different scale ranges S, F∝s^(α), wherein ∝ represents a directly proportional or scale relation between two subjects, and α is the scaling index.

In step S17, scaling index α is obtained in accordance with F∝s^(α).

Preferably, the music analysis device is configured to implement following steps.

In step S21, each music file in the music library is digitized to obtain a digital music signal sequence {U_(i), i=1, 2, . . . , M}, wherein i is the ith time point of the digital music signal sequence, and M is the length of the digital music signal sequence.

In step S22, a sequence {v_(j), j=1, 2, . . . , M/(presetlength)} is obtained by dividing the digital music signal sequence {U_(i), i=1, 2, . . . , M} into multiple sub-sequences with a preset length and calculating the standard deviation of each sub-sequence, wherein v_(j) is the jth data of the sequence {v_(j), j=1, 2, . . . , M/(presetlength)}.

In step S23, an average intensity sequence {(v_(j))², j=1, 2, . . . , M/(presetlength)} is obtained in accordance with the sequence {v_(j), j=1, 2, . . . , M/(presetlength)}.

In step S24, a fluctuation sequence {z_(b), b=1, 2, . . . , M/(presetlength)} which is a one-dimensional random walk sequence is obtained in accordance with the average intensity sequence {(v_(j))², j=1, 2, . . . , M/(presetlength)}, wherein z_(b) is the bth data of the sequence {z_(b), b=1, 2, . . . , M/(presetlength)} which is defined by the following formula.

${z_{b} = {{\sum\limits_{j = 1}^{b}\left( v_{j} \right)^{2}} - \left\langle v^{2} \right\rangle}},$ wherein

$\left\langle v^{2} \right\rangle = {\frac{1}{M/{presetlength}} \times {\sum\limits_{j = 1}^{M/{presetlength}}\;{\left( v_{j} \right)^{2}.}}}$

In step S25, multiple sub-sequences are obtained by shifting a time window with preset width along the fluctuation sequence {z_(b), b=1, 2, . . . , M/(presetlength)} {z_(b), b=1, 2, . . . , M/(presetlength)}. Each two neighboring windows exist a fixed overlap length τ.

In step S26, a linear trend {circumflex over (z)}_(b) of each sub-sequence is obtained by mean of linear regression.

In step S27, a detrended fluctuation function F_(D)(presetwidth)=√{square root over (<(δz)²>)} is obtained in accordance with the sequence {z_(b), b=1, 2, . . . , M/(presetlength)} and the linear trend of each sub-sequence, wherein δz=z_(b)−{circumflex over (z)}_(b), and <(δz)²> represents calculating the average of (δz)² in each time window.

In step S28, the long-range correlation index β is obtained in accordance with the detrended fluctuation function F_(D)(presetwidth) by means of following formula:

${\beta = \frac{d\;\log\;{F_{D}({presetwidth})}}{d\;{\log\left( {{presewidth} + 3} \right)}}},$ wherein,

$\frac{d\;\log\mspace{11mu}{F_{D}({presetwidth})}}{d\;\log\;\left( {{presewidth} + 3} \right)}$ represents the relation between detrended fluctuation function and the time scaling defined by the preset width of the time window derived from log-log plot.

Preferably, the matching device is configured to implement following steps.

In step S31. γ is calculated in accordance with the scaling index α and the long-range correlation index β, wherein, γ=|α−β|.

In step S32, if γ is within a second given range, the music file with a long-range correlation index β is matched with the electroencephalogram with a scaling index α.

1. Advantageous Effects

The method and system for matching music files with an electroencephalogram in accordance with the present invention may select corresponding music files in accordance with different electroencephalogram. In other words, the method and system in accordance with the present invention may automatically find music files matching with human brain statements in real time then guide people relieve stress and relax effectively.

BRIEF DESCRIPTION OF THE DRAWINGS

FIG. 1 is a flow chart of the method for matching an electroencephalogram and music files in accordance with a first embodiment;

FIG. 2 is a diagram of the system for matching an electroencephalogram and music files in accordance with a second embodiment.

DETAILED DESCRIPTION OF EMBODIMENTS OF THE INVENTION

For better understanding to the objects, subject matter and advantages of the embodiments in accordance with the present invention, reference will now be made in detail to particular embodiments of the disclosure, examples of which are illustrated in the accompanying drawings. Obviously, the embodiments to be introduced below should not be construed to be restrictive to the scope, but illustrative only. Those skilled in the art would understand that other embodiments obtained in accordance with the spirit of the present invention without exercising inventive skills also fall into the scope of the present invention.

The First Embodiment

A method for matching music files with an electroencephalogram is disclosed by the present embodiment which comprises following steps as illustrated in FIG. 1.

In step S1, a scaling index α is obtained in accordance with a measured electroencephalogram. In step S2, each music file in a preset music library is analyzed to obtain a long-range correlation index β. In step S3, a music file matching with the electroencephalogram is searched out in accordance with the comparison of the scaling index α and the long-range correlation index β.

Furthermore, the step S1 may comprise following steps which is not illustrated in FIG. 1.

In step S11, the measured electroencephalogram is digitized to obtain a discrete-time signal sequence {x_(i), i=1, 2, . . . , N}, wherein x_(i) is the ith sampling point of the electroencephalogram and N is the sampling size.

In step S12, the average amplitude

x

of the discrete-time signal sequence {x_(i), i=1, 2, . . . , N} is filtered to obtain a sequence {y_(i), i=1, 2, . . . , N}, wherein y_(i) is defined by the following formula.

${y_{i} = {\sum\limits_{k = 1}^{i}\;\left( {x_{k} - \left\langle x \right\rangle} \right)}},{i = {1\mspace{14mu}\ldots\mspace{20mu} N}},$ wherein,

$\left\langle x \right\rangle = {\frac{1}{N}{\sum\limits_{i = 1}^{N}{x_{i}.}}}$

In step S13, the EMD (Empirical Mode Decomposition) is applied to the sequence {y_(i), i=1, 2, . . . , N} to obtain n intrinsic mode functions IMF and a remainder R, wherein n is a positive integer determined by the EMD.

In step S14, peak-peak intervals (the number of data points between each neighboring local maximum) in each intrinsic mode function IMF are calculated.

In step S15, waveforms between peaks with peak-peak intervals within a first given range S is merged into a new waveform Pvalue_(s)(k), wherein 10^((m-1))≤s≤10^(m), m=1, 2, . . . , m_(max), and m_(max) is determined by the length N of the sequence {y_(i), i=1, 2, . . . , N}, and k represents each data point of the merged waveform, wherein k=1, 2, . . . , k_(max) and k_(max) is determined by the sum of all the peak-peak intervals within the first preset range S.

In step S16, a root mean square of each merged waveform is calculated to obtain a wave function F.

${F = \left\lbrack {\frac{1}{Q}{\sum\limits_{k = 1}^{Q}{{Pvalue}_{s}^{2}(k)}}} \right\rbrack^{1/2}},$ wherein,

${Q = \frac{k_{\max}}{\left\langle s \right\rangle}},$ and <S> represents calculating an average in range S. With respect to different scale ranges S, F∝s^(α), wherein ∝ directly proportional or scale relation between two subjects, and α is the scaling index.

In step S17, scaling index α is obtained in accordance with F∝s^(α).

Furthermore, the step S2 may comprise following steps which is not illustrated in FIG. 1.

In step S21, each music file in the music library is digitized to obtain a digital music signal sequence {U_(i), i=1, 2, . . . , M}, wherein i is the ith time point of the digital music signal sequence, and M is the length of the digital music signal sequence.

In step S22, a sequence {v_(j), j=1, 2, . . . , M/(presetlength)} is obtained by dividing the digital music signal sequence {U_(i), i=1, 2, . . . , M} into multiple sub-sequences with a preset length and calculating the standard deviation of each sub-sequence, wherein v_(j) is the jth data of the sequence {v_(j), j=1, 2, . . . , M/(presetlength)}.

In step S23, an average intensity sequence {(v_(j))², j=1, 2, . . . , M/(presetlength)} is obtained in accordance with the sequence {v_(j), j=1, 2, . . . , M/(presetlength)}.

In step S24, a fluctuation sequence {z_(b), b=1, 2, . . . , M/(presetlength)} which is a one-dimensional random walk sequence is obtained in accordance with the average intensity sequence {(v_(j))², j=1, 2, . . . , M/(presetlength)}, wherein z_(b) is the bth data of the sequence {z_(b), b=1, 2, . . . , M/(presetlength)} which is defined by the following formula.

${z_{b} = {{\sum\limits_{j = 1}^{b}\;\left( v_{j} \right)^{2}} - \left\langle v^{2} \right\rangle}},$ wherein

$\left\langle v^{2} \right\rangle = {\frac{1}{M/{presetlength}} \times {\sum\limits_{j = 1}^{M/{presetlength}}{\left( v_{j} \right)^{2}.}}}$

In step S25, multiple sub-sequences are obtained by shifting a time window with preset width along the fluctuation sequence {z_(b), b=1, 2, . . . , M/(presetlength)}. Each two neighboring windows exist a fixed overlap length τ.

In step S26, a linear trend {circumflex over (z)}_(b) of each sub-sequence is obtained by mean of linear regression, wherein, {circumflex over (z)}_(b)=a+cr, and a and c are determined by linear regression, and the multiple sub-sequences correspond to multiple {circumflex over (z)}_(b), a and c in each {circumflex over (z)}_(b)=a+cr may be different.

In step S27, a detrended fluctuation function F_(D)(presetwidth)=√{square root over (<(δz)²>)} is obtained in accordance with the sequence {z_(b), b=1, 2, . . . , M/(presetlength)} and the linear trend of each sub-sequence, wherein δz=z_(b)−{circumflex over (z)}_(b), and <(δz)²> represents calculating the average of (δz)² in each time window.

In step S28, the long-range correlation index β is obtained in accordance with the detrended fluctuation function F_(D)(presetwidth) by means of following formula:

${\beta = \frac{d\;\log\mspace{11mu}{F_{D}({presetwidth})}}{d\;\log\;\left( {{presewidth} + 3} \right)}},$ wherein,

$\frac{d\;\log\;{F_{D}({presetwidth})}}{d\;{\log\left( {{presewidth} + 3} \right)}}$ represents the relation between detrended fluctuation function and the time scaling defined by the preset width of the time window derived from log-log plot.

The step S3 may comprise following steps which is not illustrated in FIG. 1.

In step S31. γ is calculated in accordance with the scaling index α and the long-range correlation index β, wherein, γ=|α−β|.

In step S32, if γ is with a second given range, the music file with a long-range correlation index β is matched with the electroencephalogram with a scaling index α.

The method in accordance with the present embodiment compares the scaling index α of an electroencephalogram with the long-range correlation index β, and matches music file with the electroencephalogram if the scaling index and the long-range correlation index close to equal so as to find a music file matching with a measured electroencephalogram automatically. The method in accordance with the present embodiment may find music files match with human brain state automatically in real time by measuring an electroencephalogram then guide people relieve stress and relax effectively.

The Second Embodiment

A system for matching music files with an electroencephalogram is disclosed by the present embodiment which comprises an electroencephalogram scaling device, a music analysis device and a matching device as illustrated in FIG. 1.

The electroencephalogram scaling device is configured to obtain a scaling index α in accordance with a measured electroencephalogram and to transmit the scaling index α to the matching device. The music analysis device is configured to analyze each music file in a preset music library to obtain a long-range correlation index β and to transmit β to the matching device. The matching device is configured to search out a music file matching with the electroencephalogram in accordance with the comparison of the scaling index α and the long-range correlation index β.

The system further comprises an electroencephalogram measuring device not illustrated in FIG. 1. The electroencephalogram measuring device is configured to measure an electroencephalogram and to transmit the electroencephalogram to the electroencephalogram scaling device.

In a preferable embodiment, the electroencephalogram scaling device is configured to implement following steps.

In step S11, the measured electroencephalogram is digitized to obtain a discrete-time signal sequence {x_(i), i=1, 2, . . . , N}, wherein xi is the ith sampling point of the electroencephalogram and N is the sampling size.

In step S12, the average amplitude

x

of the discrete-time signal sequence {x_(i), i=1, 2, . . . , N} is filtered to obtain a sequence {y_(i), i=1, 2, . . . , N}, wherein y_(i) is defined by the following formula.

${y_{i} = {\sum\limits_{k = 1}^{i}\left( {x_{k} - \left\langle x \right\rangle} \right)}},{i = {1\mspace{14mu}\ldots\mspace{20mu} N}},$ wherein

$\left\langle x \right\rangle = {\frac{1}{N}{\sum\limits_{i = 1}^{N}{x_{i}.}}}$

In step S13, the EMD (Empirical Mode Decomposition) is applied to the sequence {y_(i), i=1, 2, . . . , N} to obtain n intrinsic mode functions IMF and a remainder R, wherein n is a positive integer determined by the EMD.

In step S14, peak-peak intervals (the number of data points between each neighboring local maximum) in each intrinsic mode function IMF are calculated.

In step S15, waveforms between peaks with peak-peak intervals with length within a first given range S are merged into a new waveform Pvalue_(s)(k), wherein 10^((m-1))≤s≤10^(m), m=1, 2, . . . , m_(max), and m_(max) is determined by the length N of the sequence {y_(i), i=1, 2, . . . , N}, and k represents each data point of the merged waveform, wherein k=1, 2, . . . , k_(max) and k_(max) is determined by the sum of all the peak-peak intervals within the first given range S.

In step S16, root mean square of each merged waveform is calculated to obtain a wave function F.

${F = \left\lbrack {\frac{1}{Q}{\sum\limits_{k = 1}^{Q}{{Pvalue}_{s}^{2}(k)}}} \right\rbrack^{1/2}},$ wherein,

${Q = \frac{k_{\max}}{\left\langle s \right\rangle}},$ and <S> represents calculating an average in range S. With respect to different scale ranges S, F∝s^(α), wherein ∝ represents a directly proportional or scale relation between two subjects, and α is the scaling index.

In step S17, scaling index α is obtained in accordance with F∝s^(α).

More specifically, the music analysis device is configured to implement following steps.

In step S21, each music file in the music library is digitized to obtain a digital music signal sequence {U_(i), i=1, 2, . . . , M}, wherein i is the ith time point of the digital music signal sequence, and M is the length of the digital music signal sequence.

In step S22, a sequence {v_(j), j=1, 2, . . . , M/(presetlength)} is obtained by dividing the digital music signal sequence {U_(i), i=1, 2, . . . , M} into multiple sub-sequences with a preset length and calculating the standard deviation of each sub-sequence, wherein v_(j) is the jth data of the sequence {v_(j), j=1, 2, . . . , M/(presetlength)}.

In step S23, an average intensity sequence {(v_(j))², j=1, 2, . . . , M/(presetlength)} is obtained in accordance with the sequence {v_(j), j=1, 2, . . . , M/(presetlength)}.

In step S24, a fluctuation sequence {z_(b), b=1, 2, . . . , M/(presetlength)} which is a one-dimensional random walk sequence is obtained in accordance with the average intensity sequence {(v_(j))², j=1, 2, . . . , M/(presetlength)}, wherein z_(b) is the bth data of the sequence {z_(b), b=1, 2, . . . , M/(presetlength)} which is defined by the following formula.

${z_{b} = {{\sum\limits_{j = 1}^{b}\;\left( v_{j} \right)^{2}} - \left\langle v^{2} \right\rangle}},$ wherein

$\left\langle v^{2} \right\rangle = {\frac{1}{M/{presetlength}} \times {\sum\limits_{j = 1}^{M/{presetlength}}\;{\left( v_{j} \right)^{2}.}}}$

In step S25, multiple sub-sequences are obtained by shifting a time window with preset width along the fluctuation sequence {z_(b), b=1, 2, . . . , M/(presetlength)}. Each two neighboring windows exist a fixed overlap length τ.

In step S26, a linear trend {circumflex over (z)}_(b) of each sub-sequence is obtained by mean of linear regression.

In step S27, a detrended fluctuation function F_(D)(presetwidth)=√{square root over (<(δz)²>)} is obtained in accordance with the sequence {z_(b), b=1, 2, . . . , M/(presetlength)} and the linear trend of each sub-sequence, wherein δz=z_(b)−{circumflex over (z)}_(b), and <(δz)²> represents calculating the average of (δz)² in each time window.

In step S28, the long-range correlation index β is obtained in accordance with the detrended fluctuation function F_(D)(presetwidth) by means of following formula:

${\beta = \frac{d\;\log\;{F_{D}({presetwidth})}}{d\;{\log\left( {{presewidth} + 3} \right)}}},$ wherein,

$\frac{\;{d\;\log\mspace{11mu}{F_{D}({presetwidth})}}}{d\;\log\;\left( {{presewidth} + 3} \right)}$ represents the relation between detrended fluctuation function and the time scaling defined by the preset width of the time window derived from log-log plot.

More specifically, the matching device is configured to implement following steps.

In step S31. γ is calculated in accordance with the scaling index α and the long-range correlation index β, wherein, γ=|α−β|.

In step S32, if γ is within a second given range, the music file with a long-range correlation index β is matched with the electroencephalogram with a scaling index α.

The system in accordance with the present embodiment may automatically find music files matching with human brain statements in real time by measuring an electroencephalogram, and then guide people relieve stress and relax effectively.

While embodiments of this disclosure have been shown and described, it will be apparent to those skilled in the art that more modifications are possible without departing from the spirits herein. The disclosure, therefore, is not to be restricted except in the spirit of the following claims.

The method and system for matching music files with an electroencephalogram in accordance with the present invention may select corresponding music files in accordance with different electroencephalogram. In other words, the method and system in accordance with the present invention may automatically find music files matching with human brain statements in real time by measuring an electroencephalogram, and then guide people relieve stress and relax effectively. 

We claim:
 1. A computer-implemented method for matching music files with an electroencephalogram, comprising: obtaining a scaling index α in accordance with a measured electroencephalogram; analyzing each music file in a preset music library to obtain a long-range correlation index β; searching out a music file which matches the electroencephalogram in accordance with the comparison of the scaling index α and the long-range correlation index β; and playing, via a music player, the music file which matches the electroencephalogram, wherein said obtaining a scaling index α further comprises: digitizing said measured electroencephalogram to obtain a discrete-time signal sequence {x_(i), i=1, 2, . . . , N}, wherein x_(i) is the ith sampling point of said electroencephalogram and N is the sampling size; filtering the average amplitude

x

from said discrete-time signal sequence {x_(i), i=1, 2, . . . , N} to obtain a sequence {y_(i), i=1, 2, . . . , N}, wherein y_(i) is defined by the following formula, ${y_{i} = {\sum\limits_{k = 1}^{i}\;\left( {x_{k} - \left\langle x \right\rangle} \right)}},{i = {1\mspace{14mu}\ldots\mspace{25mu} N}},$  wherein, ${\left\langle x \right\rangle = {\frac{1}{N}{\sum\limits_{i = 1}^{N}\; x_{i}}}};$ applying an Empirical Mode Decomposition (EMD) to said sequence {y_(i), i=1, 2, . . . , N} to obtain n intrinsic mode functions and a remainder, wherein n is a positive integer determined by said EMD; calculating peak-peak intervals in each intrinsic mode function; merging waveforms between peaks with peak-peak intervals within a first given range S into a new waveform Pvalue_(s)(k), wherein 10^((m-1))≤s≤10^(m), m=1, 2, . . . , m_(max), and m_(max) is determined by the length N of said sequence {y_(i), i=1, 2, . . . , N}, and k represents each data point of said merged waveform, wherein k=1, 2, . . . , k_(max), and k_(max) is determined by the sum of all the peak-peak intervals within the first given range S; calculating a root mean square of each merged waveform to obtain a wave function F, wherein, ${F = \left\lbrack {\frac{1}{Q}{\sum\limits_{k = 1}^{Q}\;{{Pvalue}_{s}^{2}(k)}}} \right\rbrack^{1/2}},$  wherein, ${Q = \frac{k_{\max}}{\left\langle s \right\rangle}},$  and <S> represents calculating an average in range S, and with respect to different scale ranges S, F∝s^(α), wherein ∝ represents a directly proportional or scale relation between two subjects, and α is the scaling index; and obtaining scaling index α in accordance with F∝s^(α).
 2. The method of claim 1, wherein, said analyzing each music file further comprises: digitizing each music file in the music library to obtain a digital music signal sequence {U_(i), i=1, 2, . . . , M}, wherein i is the ith time point of said digital music signal sequence, and M is the length of said digital music signal sequence; obtaining a sequence {v_(j), j=1, 2, . . . , M/(presetlength)} by dividing said digital music signal sequence {U_(i), i=1, 2, . . . , M} into multiple sub-sequences with a preset length and calculating the standard deviation of each sub-sequence, wherein v_(j) is the jth data of said sequence {v_(j), j=1, 2, . . . , M/(presetlength)}; obtaining an average intensity sequence in accordance with the sequence {v_(j), j=1, 2, . . . , M/(presetlength)}; obtaining a fluctuation sequence {z_(b), b=1, 2, . . . , M/(presetlength)} which is a one-dimensional random walk sequence in accordance with the average intensity sequence {(v_(j))², j=1, 2, . . . , M/(presetlength)}, wherein z_(b) is the bth data of the sequence {z_(b), b=1, 2, . . . , M/(presetlength)} which is defined by the following formula, ${z_{b} = {{\sum\limits_{j = 1}^{b}\;\left( v_{j} \right)^{2}} - \left\langle v^{2} \right\rangle}},$  wherein ${\left\langle v^{2} \right\rangle = {\frac{1}{M/{presetlength}} \times {\sum\limits_{j = 1}^{M/{presetlength}}\;\left( v_{j} \right)^{2}}}};$ obtaining multiple sub-sequences by shifting a time window with preset width along said fluctuation sequence {z_(b), b=1, 2, . . . , M/(presetlength)} with each two neighboring windows exist a fixed overlap length τ; obtaining a linear trend {circumflex over (z)}_(b) of each sub-sequence by mean of linear regression; obtaining a detrended fluctuation function F_(D)(presetwidth)=√{square root over (<(δz)²>)} in accordance with said sequence {z_(b), b=1, 2, . . . , M/(presetlength)} and said linear trend of each sub-sequence, wherein δz=z_(b)−{circumflex over (z)}_(b), and <(δz)²> represents calculating the average of (δz)² in the time window; and obtaining said long-range correlation index β in accordance with said detrended fluctuation function F_(D)(presetwidth) by means of following formula: ${\beta = \frac{d\;\log\;{F_{D}({presetwidth})}}{d\;{\log\left( {{presewidth} + 3} \right)}}},$  wherein, $\frac{d\;\log\;{F_{D}({presetwidth})}}{d\;{\log\left( {{presewidth} + 3} \right)}}$  represents the relation between said detrended fluctuation function and the time scaling defined by said preset width of said time window derived from log-log plot.
 3. The method of claim 1, wherein, said searching out a music file further comprises: calculating γ in accordance with the scaling index α and the long-range correlation index β, wherein, γ=|α−β|; and if γ is within a second given range, the music file with said long-range correlation index β is matched with the electroencephalogram with said scaling index α.
 4. A system for matching music files with an electroencephalogram, comprising: a music player; an electroencephalogram scaling device configured to obtain a scaling index α in accordance with a measured electroencephalogram and to transmit said scaling index α to a matching device; a music analysis device configured to analyze each music file in a preset music library to obtain a long-range correlation index β and to transmit β to said matching device; and a matching device configured to search out a music file matching with the electroencephalogram in accordance with the comparison of the scaling index α and the long-range correlation index β and cause the music player to play the music file which matches the electroencephalogram, wherein said electroencephalogram scaling device is configured to implement following steps: digitizing said measured electroencephalogram to obtain a discrete-time signal sequence {x_(i), i=1, 2, . . . , N}, wherein x_(i) is the ith sampling point of said electroencephalogram and N is the sampling size; filtering the average amplitude

x

from said discrete-time signal sequence {x_(i), i=1, 2, . . . , N} to obtain a sequence {y_(i), i=1, 2, . . . , N}, wherein y_(i) is defined by the following formula, ${y_{i} = {\sum\limits_{k = 1}^{i}\;\left( {x_{k} - \left\langle x \right\rangle} \right)}},{i = {1\mspace{14mu}\ldots\mspace{14mu} N}},$  wherein ${\left\langle x \right\rangle = {\frac{1}{N}{\sum\limits_{i = 1}^{N}\; x_{i}}}};$ applying an Empirical Mode Decomposition (EMD) to said sequence {y_(i), i=1, 2, . . . , N} to obtain n intrinsic mode functions and a remainder, wherein n is a positive integer determined by said EMD; calculating peak-peak intervals in each intrinsic mode function; merging waveforms between peaks with peak-peak intervals within a first given range S into a new waveform Pvalue_(s)(k), wherein 10^((m-1))≤s≤10^(m), m=1, 2, . . . , m_(max), and m_(max) is determined by the length N of said sequence, {y_(i), i=1, 2, . . . , N}, and k represents each data point of said merged waveform, wherein k=1, 2, . . . , k_(max), and k_(max) is determined by the sum of all the peak-peak intervals within the first given range S; calculating a root mean square of each merged waveform to obtain a wave function F, wherein, ${F = \left\lbrack {\frac{1}{Q}{\sum\limits_{k = 1}^{Q}\;{{Pvalue}_{s}^{2}(k)}}} \right\rbrack^{1/2}},$  wherein, ${Q = \frac{k_{\max}}{\left\langle s \right\rangle}},$  and <S> represents calculating an average in range S, and with respect to different scale ranges S, F∝s^(α), wherein ∝ represents a directly proportional or scale relation between two subjects, and α is the scaling index; and obtaining scaling index α in accordance with F∝s^(α).
 5. The system of claim 4, wherein, said system further comprises an electroencephalogram measuring device configured to measure an electroencephalogram and to transmit the electroencephalogram to the electroencephalogram scaling device.
 6. The system of claim 4, wherein, said music analyzing device is configured to implement following steps: digitizing each music file in the music library to obtain a digital music signal sequence {U_(i), i=1, 2, . . . , M}, wherein i is the ith time point of said digital music signal sequence, and M is the length of said digital music signal sequence; obtaining a sequence {v_(j), j=1, 2, . . . , M/(presetlength)} by dividing said digital music signal sequence {U_(i), i=1, 2, . . . , M} into multiple sub-sequences with a preset length and calculating the standard deviation of each sub-sequence, wherein v_(j) is the jth data of said sequence {v_(j), j=1, 2, . . . , M/(presetlength)}; obtaining an average intensity sequence in accordance with the sequence {v_(j), j=1, 2, . . . , M/(presetlength)}; obtaining a fluctuation sequence {z_(b), b=1, 2, . . . , M/(presetlength)} which is a one-dimensional random walk sequence in accordance with the average intensity sequence {(v_(j))², j=1, 2, . . . , M/(presetlength)}, wherein z_(b) is the bth data of the sequence {z_(b), b=1, 2, . . . , M/(presetlength)} which is defined by the following formula, ${z_{b} = {{\sum\limits_{j = 1}^{b}\;\left( v_{j} \right)^{2}} - \left\langle v^{2} \right\rangle}},$  wherein ${\left\langle v^{2} \right\rangle = {\frac{1}{M/{presetlength}} \times {\sum\limits_{j = 1}^{M/{presetlength}}\;\left( v_{j} \right)^{2}}}};$ obtaining multiple sub-sequences by shifting a time window with preset width along said fluctuation sequence {z_(b), b=1, 2, . . . , M/(presetlength)} with each two neighboring windows exist a fixed overlap length τ; obtaining a linear trend {circumflex over (z)}_(b) of each sub-sequence by mean of linear regression; obtaining a detrended fluctuation function F_(D)(presetwidth)=√{square root over (<(δz)²>)} in accordance with said sequence {z_(b), b=1, 2, . . . , M/(presetlength)} and said linear trend of each sub-sequence, wherein δz=z_(b)−{circumflex over (z)}_(b), and <(δz)²> represents calculating the average of (δz)² in the time window; and obtaining said long-range correlation index β in accordance with said detrended fluctuation function F_(D)(presetwidth) by means of following formula: ${\beta = \frac{d\;\log\;{F_{D}({presetwidth})}}{d\;{\log\left( {{presewidth} + 3} \right)}}},$  wherein, $\frac{d\;\log\;{F_{D}({presetwidth})}}{d\;{\log\left( {{presewidth} + 3} \right)}}$  represents the relation between said detrended fluctuation function and the time scaling defined by said preset width of said time window derived from log-log plot.
 7. The system of claim 4, wherein, said matching device is configured to implement following steps: calculating γ in accordance with the scaling index α and the long-range correlation index β, wherein, γ=|α−β|; and if γ is within a second given range, the music file with said long-range correlation index β is matched with the electroencephalogram with said scaling index α.
 8. A computer-implemented method for selecting a music file in a music library for relaxing a user, comprising: obtaining a scaling index α of a measured electroencephalogram of the user; obtaining a long-range correlation index β of each of music files in the music library; selecting one of the music files, whose long-range correlation index β matches the scaling index α of the measured electroencephalogram; and playing, via a music player, the selected music file for the user, wherein said obtaining a scaling index α further comprises: digitizing said measured electroencephalogram to obtain a discrete-time signal sequence {x_(i), i=1, 2, . . . , N}, wherein x_(i) is the ith sampling point of said electroencephalogram and N is the sampling size; filtering the average amplitude

x

from said discrete-time signal sequence {x_(i), i=1, 2, . . . , N} to obtain a sequence {y_(i), i=1, 2, . . . , N}, wherein y_(i) is defined by the following formula, ${y_{i} = {\sum\limits_{k = 1}^{i}\left( {x_{k} - \left\langle x \right\rangle} \right)}},{i = {1\mspace{14mu}\ldots\mspace{14mu} N}},$  wherein, ${\left\langle x \right\rangle = {\frac{1}{N}{\sum\limits_{i = 1}^{N}x_{i}}}};$ applying an Empirical Mode Decomposition (EMD) to said sequence {y_(i), i=1, 2, . . . , N} to obtain n intrinsic mode functions and a remainder, wherein n is a positive integer determined by said EMD; calculating peak-peak intervals in each intrinsic mode function; merging waveforms between peaks with peak-peak intervals within a first given range S into a new waveform Pvalue_(s)(k), wherein 10^((m-1))≤s≤10^(m), m=1, 2, . . . , m_(max), and m_(max) is determined by the length N of said sequence {y_(i), i=1, 2, . . . , N}, and k represents each data point of said merged waveform, wherein k=1, 2, . . . , k_(max), and k_(max) is determined by the sum of all the peak-peak intervals within the first given range S; calculating a root mean square of each merged waveform to obtain a wave function F, wherein, ${F = \left\lbrack {\frac{1}{Q}{\sum\limits_{k = 1}^{Q}{{Pvalue}_{s}^{2}(k)}}} \right\rbrack^{1/2}},$  wherein, ${Q = \frac{k_{m\; a\; x}}{\left\langle s \right\rangle}},$  and <S> represents calculating an average in range S, and with respect to different scale ranges S, F∝s^(α), wherein ∝ represents a directly proportional or scale relation between two subjects, and α is the scaling index; and obtaining scaling index α in accordance with F∝s^(α).
 9. The method of claim 8, wherein, said analyzing each music file further comprises: digitizing each music file in the music library to obtain a digital music signal sequence {U_(i), i=1, 2, . . . , M}, wherein i is the ith time point of said digital music signal sequence, and M is the length of said digital music signal sequence; obtaining a sequence {v_(j), j=1, 2, . . . , M/(presetlength)} by dividing said digital music signal sequence {U_(i), i=1, 2, . . . , M} into multiple sub-sequences with a preset length and calculating the standard deviation of each sub-sequence, wherein v_(j) is the jth data of said sequence {v_(j), j=1, 2, . . . , M/(presetlength)}; obtaining an average intensity sequence in accordance with the sequence {v_(j), j=1, 2, . . . , M/(presetlength)}; obtaining a fluctuation sequence {z_(b), b=1, 2, . . . , M/(presetlength)} which is a one-dimensional random walk sequence in accordance with the average intensity sequence {(v_(j))², j=1, 2, . . . , M/(presetlength)}, wherein z_(b) is the bth data of the sequence {z_(b), b=1, 2, . . . , M/(presetlength)} which is defined by the following formula, ${z_{b} = {{\sum\limits_{j = 1}^{b}\left( v_{j} \right)^{2}} - \left\langle v^{2} \right\rangle}},$  wherein ${\left\langle v^{2} \right\rangle = {\frac{1}{M/{presetlength}} \times {\sum\limits_{j = 1}^{M/{presetlength}}\left( v_{j} \right)^{2}}}};$ obtaining multiple sub-sequences by shifting a time window with preset width along said fluctuation sequence {z_(b), b=1, 2, . . . , M/(presetlength)} with each two neighboring windows exist a fixed overlap length τ; obtaining a linear trend {circumflex over (z)}_(b) of each sub-sequence by mean of linear regression; obtaining a detrended fluctuation function F_(D) (presetwidth)=√{square root over (<(δz)²>)} in accordance with said sequence {z_(b), b=1, 2, . . . , M/(presetlength)} and said linear trend of each sub-sequence, wherein δz=z_(b)−{circumflex over (z)}_(b), and <(δz)²> represents calculating the average of (δz)² in the time window; and obtaining said long-range correlation index β in accordance with said detrended fluctuation function F_(D)(presetwidth) by means of following formula: ${\beta = \frac{d\;\log\;{F_{D}({presetwidth})}}{d\;\log\;\left( {{presewidth} + 3} \right)}},$  wherein, $\frac{d\;\log\;{F_{D}({presetwidth})}}{d\;\log\;\left( {{presewidth} + 3} \right)}$  represents the relation between said detrended fluctuation function and the time scaling defined by said preset width of said time window derived from log-log plot.
 10. The method of claim 9, wherein, said searching out a music file further comprises: calculating γ in accordance with the scaling index α and the long-range correlation index β, wherein, γ=|α−β|; and if γ is within a second given range, the music file with said long-range correlation index β is matched with the electroencephalogram with said scaling index α. 